package com.dianzi.certification.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dianzi.certification.entity.CorrectImprove;
import com.dianzi.certification.vo.CorrectImproveVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @author copa
 * @createDate 2022-03-30 22:25
 * @function
 */
@Repository
public interface CorrectImproveMapper extends BaseMapper<CorrectImprove> {

    @Select("SELECT pse.first_level_point firstLevelPoint, pse.second_level_point secondLevelPoint, pse.improve_method improveMethod, IFNULL(ci.correct_status,0) correctStatus   " +
            "FROM certification c   " +
            "LEFT JOIN correct_improve ci ON c.id = ci.cert_id   " +
            "LEFT JOIN profession_self_evaluation pse ON c.id = pse.cert_id   " +
            "WHERE c.cert_stage = 3 AND c.cert_status = 2 AND c.principal_id = #{userId}   " +
            "ORDER BY c.id DESC LIMIT 1")
    CorrectImproveVO selectImprove(@Param("userId") Integer userId);
}
